<template>
	<view style="background: #ffffff;">
		<view style="padding:0upx 20upx" v-if="article">
			<view class="title">{{ article.title }}</view>
			<view class="info">发布时间：{{ GMTToStr(article.created_at) }}</view>

			<rich-text class="content" v-if="!article.edit_content" :nodes="article.content"></rich-text>
			<rich-text class="content" v-if="article.edit_content" :nodes="article.edit_content"></rich-text>

			<view v-if="article.edit_content" class="info">已编辑</view>
		</view>
	</view>
</template>

<script>
	import * as API from 'server/getData'

	export default {
		data() {
			return {
				article: null
			}
		},
		onLoad(e) {
			this.initData(e.id)

		},
		methods: {
			async initData(id) {
				let res = await API.articles.fetchArticle({id})
				this.article = res.data
			},
			GMTToStr(time) {
				let date = new Date(time)
				let Str=date.getFullYear() + '-' +
				(date.getMonth() + 1) + '-' +
				date.getDate() + ' ' +
				date.getHours() + ':' +
				date.getMinutes() + ':' +
				date.getSeconds()
				return Str
			},
		}
	}
</script>

<style>
.title {
	font-size: 26px;
	line-height: 1.4em;
	padding-top: 10px;
}

.info {
	line-height: 1.5em;
	border-bottom: 1px solid #e2e2e2;
	margin: 10px 0px;
	padding: 10px 0px;
}

.content {
	line-height: 1.5em;
	font-size: 16px;
}
</style>
